﻿using System;
using System.Windows.Input;

namespace BookSourceVerification.common;

public class BaseCommand : ICommand
{
    public Action<object?> DoExecute { get; set; }
    public Func<object?, bool> CanDoExecute { get; set; }

    public bool CanExecute(object? parameter)
    {
        return CanDoExecute(parameter);
    }

    public void Execute(object? parameter)
    {
        DoExecute?.Invoke(parameter);
    }

    public void RaiseCanExecuteChanged()
    {
        CanExecuteChanged?.Invoke(this, EventArgs.Empty);
    }

    public event EventHandler? CanExecuteChanged;
}